package com.jsbs.iam.auth.controller;

import com.jsbs.iam.auth.dto.IamRoleDto;
import com.jsbs.iam.auth.service.IamRoleService;
import com.jsbs.iam.common.core.dto.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhouxiangyang
 * @className RoleApplyController
 * @date 2022/12/15 17:22
 * @description:
 */
@RestController
@RequestMapping("/iam/auth/roleApply")
public class RoleApplyController {

    @Autowired
    private IamRoleService iamRoleService;

    @RequestMapping("/getApplyCodeList")
    public Result<List<String>> getApplyCodeList (@RequestBody IamRoleDto iamRoleDto) {
        if (iamRoleDto != null) {
            //根据用户id查询应用编码
            List<String> applyCodeList = iamRoleService.getApplyCodeList(iamRoleDto.getUserCode());
            return Result.success(applyCodeList);
        } else {
            return Result.fail("角色编码为空，请确认入参");
        }
    }
}
